<?php
/**
 * Includes extended FileInfo class.
 *
 * @category    Development
 * @package 	mpPackager
 * @subpackage  FileInfo
 * @author		Murat Purc <murat@purc.de>
 * @copyright   Copyright (c) 2009-2010 Murat Purc (http://www.purc.de)
 * @license     http://www.gnu.org/licenses/gpl-2.0.html - GNU General Public License, version 2
 * @version     $Id: FileInfo.php 2 2010-04-11 18:09:46Z purcaholic $
 */


/**
 * Extended SplFileInfo class. Wrapps some methods who return path related data.
 *
 * Is used to get rid of the Windows backslash path separator...
 *
 * @category    Development
 * @package 	mpPackager
 * @subpackage  FileInfo
 * @author		Murat Purc <murat@purc.de>
 */
class mpPackager_FileInfo extends SplFileInfo
{
    /**
     * Returns an SplFileInfo object for the file.
     * Wrapper of parents getFileInfo() method.
     *
     * @return  mpPackager_FileInfo
     */
    public function getFileInfo()
    {
        return parent::getFileInfo('mpPackager_FileInfo');
    }


    /**
     * Returns the path without filename.
     * Wrapper of parents getPath() method.
     *
     * @return  string
     */
    public function getPath()
    {
        return $this->_normalizePathSeparator(parent::getPath());
    }


    /**
     * Returns the path to the file/folder
     * Wrapper of parents getPathname() method.
     *
     * @return  string
     */
    public function getPathname()
    {
        return $this->_normalizePathSeparator(parent::getPathname());
    }


    /**
     * Returns the absolute path to the file/folder
     * Wrapper of parents getRealPath() method.
     *
     * @return  string
     */
    public function getRealPath()
    {
        return $this->_normalizePathSeparator(parent::getRealPath());
    }


    /**
     * Normalizes the path separator. Replaces Windows path separator (\\) against
     * crosssystem version (/).
     *
     * @param   string  $path
     * @return  string
     */
    private function _normalizePathSeparator($path)
    {
        if (DIRECTORY_SEPARATOR == '\\') {
            $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
        }
        return $path;
    }

}